package com.ruoyi.web.controller;


import cn.hutool.core.map.MapUtil;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.BAssist;
import com.ruoyi.system.domain.vo.BAssistVo;
import com.ruoyi.system.service.BAssistService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/assist")
public class AssistController extends BaseController {

    @Autowired
    private BAssistService assistService;


    /**
     * 获取指南辅助列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BAssist bAssist)
    {
        startPage();
        List<BAssistVo> list = assistService.selectAssistList(bAssist);
        return getDataTable(list);
    }

    /**
     * 新增指南辅助
     */
    @PostMapping
    public AjaxResult add(@Validated @RequestBody BAssist assist)
    {
        assist.setCreateBy(getUsername());
        assist.setCreateTime(new Date());
        assistService.save(assist);

        return AjaxResult.success(MapUtil.builder().put("id",assist.getId()).build());

    }
}
